package com.fu.controller;

import com.fu.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@org.springframework.stereotype.Controller("/hello")
public class MyController implements Controller {
    @Autowired
    HelloService helloService;

    /**
     * 这个方法是用来处理请求
     * @param request  前端发送来的请求
     * @param response  服务端给前端的响应
     * @return          返回ModelAndView，Model相当于数据模型，View相当于视图
     * @throws Exception
     */
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

        ModelAndView mv = new ModelAndView("hello");
        mv.addObject("name","fushijie");
        System.out.println(helloService.hello("FuShiJIE"));
        return mv;
    }
}
